package org.neptune.service.rabbit;

import javax.websocket.Session;

import org.neptune.common.constant.NeptuneConstant;
import org.neptune.service.util.CommentMqBean;
import org.neptune.service.util.WebUtil;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author lwl
 * @date 2019/11/25 14:44
 */
@Component
public class CommentProducer {

	@Autowired
	private AmqpTemplate amqpTemplate;

	public void sender(Session session, String msg) {
		CommentMqBean commentMqBean = new CommentMqBean();
		commentMqBean.setUserName(WebUtil.getNickName(WebUtil.getWebsocketUser(session)));
		commentMqBean.setMsg(msg);
		amqpTemplate.convertAndSend(NeptuneConstant.HOME_COMMENT_QUENE_NAME, commentMqBean);
	}

}
